package fr.xebia.data;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

/**
 * 
 */
@Entity
@Table(name = "contract_type")
public class ContractType implements Serializable {

	private static final long serialVersionUID = 1L;

	private Long id;
	private String name;

	/**
	 * Gets the id
	 * 
	 * @returns the id
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Long getId() {
		return this.id;
	}

	/**
	 * Sets the id
	 * 
	 * @param the
	 *            id
	 */
	public void setId(Long pId) {
		this.id = pId;
	}

	/**
	 * Gets the name
	 * 
	 * @returns the name
	 */
	@Column(name = "NAME")
	public String getName() {
		return this.name;
	}

	/**
	 * Sets the name
	 * 
	 * @param the
	 *            name
	 */
	public void setName(String pName) {
		this.name = pName;
	}

	@Override
	public boolean equals(Object obj) {
		ContractType otherContratType = (ContractType) obj;
		EqualsBuilder equalsBuilder = new EqualsBuilder();
		equalsBuilder.append(getId(), otherContratType.getId());
		equalsBuilder.append(getName(), otherContratType.getName());
		return equalsBuilder.isEquals();
	}

	@Override
	public int hashCode() {
		HashCodeBuilder hashCodeBuilder = new HashCodeBuilder();
		hashCodeBuilder.append(getId());
		hashCodeBuilder.append(getName());
		return hashCodeBuilder.toHashCode();
	}

	@Override
	public String toString() {
		StringBuffer buffer = new StringBuffer();
		// buffer.append("ContratType");
		// buffer.append('\n');
		buffer.append("name=").append(name).append(',');
		return buffer.toString();
	}
}
